package com.xinruke.hostels.reservation.service;

import com.xinruke.hostels.common.cache.ReservationUserCache;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.reservation.user.interfaces.dto.BlacklistQueryDTO;
import com.xinruke.hostels.reservation.user.interfaces.dto.BlacklistQueryResultDTO;
import com.xinruke.hostels.reservation.interfaces.dto.ReservationContactsListQueryDTO;
import com.xinruke.hostels.reservation.user.interfaces.api.ReservationUserApi;
import com.xinruke.hostels.reservation.user.interfaces.dto.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author GuoZheng
 * @ClassName PersonalService
 * @date：2019/6/29
 * @version: V1.0.0
 * @description：
 */
@Service
@Slf4j
public class PersonalService {

    @Resource
    private ReservationUserApi reservationUserApi;
    @Autowired
    private ReservationUserCache reservationUserCache;


    public ResultVO addContacts(ContactsAddInfoDto params) {
        params.setHuiyuanId(reservationUserCache.getCurrentUserId());
        return reservationUserApi.addContacts(params);
    }

    public ResultVO<RowsDataVO<ContactsInfo>> contactsList(ReservationContactsListQueryDTO contactsListQueryDto) {
        ContactsListQueryDTO queryDTO = new ContactsListQueryDTO();
        BeanUtils.copyProperties(contactsListQueryDto, queryDTO);
        queryDTO.setUserId(reservationUserCache.getCurrentUserId());
        return reservationUserApi.contactsList(queryDTO);
    }

    public ResultVO updateContacts(ContactsUpdateDto params) {
        return reservationUserApi.updateContacts(params);
    }

    public ResultVO update(PersonalUpdateDto params) {
        return reservationUserApi.update(params);
    }

    public ResultVO delContacts(ContactsDelDto params) {
        return reservationUserApi.delContacts(params);
    }

    public ResultVO<ContactsDetailResultDto> contactdetail(ContactsDetailQueryDTO queryDTO) {
        return reservationUserApi.contactDetailInnerAPI(queryDTO);
    }

    public ResultVO<BlacklistQueryResultDTO> isBlacklist(BlacklistQueryDTO blacklistQueryDTO) {
        return reservationUserApi.isBlacklist(blacklistQueryDTO);
    }
}
